{extend name="base" /} {block name="body"}
<div class="admin-main">
    <div class="layui-field-box layui-form">
        <a href="{:url('feelym/articlecate/add')}" class="layui-btn layui-btn-sm" id="add">
            <i class="layui-icon">&#xe608;</i> 添加栏目
        </a>

        <table class="layui-table admin-table">
            <thead>
                <tr>
                    <th width="5%" align="center">ID</th>
                    <th width="20%" align="center">栏目名称</th>
                    <th width="10%" align="center">首页文字展示</th>
                    <th width="10%" align="center">首页图片展示</th>
                    <th width="10%" align="center">详情页模板</th>
                    <th width="10%" align="center">列表页模板</th>
                    <th width="15%" align="center">基本操作</th>
                </tr>
            </thead>
            <tbody>
                {volist name="category_level_list" id="vo"}
                <tr>
                    <td align="center">{$vo.id}</td>
                    <td style="padding-left: 20px;">{neq name="vo.level" value="1"}|{php}for($i=1;$i
                        <$vo[ 'level'];$i++){echo ' --';}{/php}{/neq} {$vo.name}</td>
                            <td align="center">

                                <input type="checkbox" name="textshow" lay-skin="switch" lay-text="展示|隐藏" lay-filter="switchtextshow" value="{$vo['id']}" {php}echo $vo[ 'hometextshow']==1 ? 'checked' : '';{/php}>
                            </td>
                            <td align="center">

                                <input type="checkbox" name="picshow" lay-skin="switch" lay-text="展示|隐藏" lay-filter="switchpicshow" value="{$vo['id']}" {php}echo $vo[ 'homepicshow']==1 ? 'checked' : '';{/php}>
                            </td>
                            <td align="center">{$vo.template}</td>
                            <td align="center">{$vo.list_template}</td>
                            <td align="center">
                                <a class="layui-btn layui-btn-normal layui-btn-sm" href="{:url('feelym/articlecate/edit',array('id'=>$vo['id']))}">修改</a>
                                <a href="javascript:;" data-id="{$vo.id}" data-url="{:url('feelym/articlecate/delete',array('id'=>$vo['id']))}" data-opt="del" class="elementdel layui-btn layui-btn-danger layui-btn-sm ajax-delete">删除</a>
                            </td>
                </tr>
                {/volist}
            </tbody>
        </table>
    </div>


</div>
{/block} {block name="js"}
<script type="text/javascript" src="__ADMIN__/js/delelement.js"></script>
{/block} {block name="script"}
<script>
    layui.use(['form'], function() {
        var form = layui.form,
            jq = layui.jquery;


        //jq('.btable-paged').eq(1).hide();
        var status = 0;
        form.on('switch(switchTest)', function(data) {
            loading = layer.load(2, {
                shade: [0.2, '#000']
            });
            if (data.elem.checked) {
                status = 1;
            } else {
                status = 0;
            }
            var url = "{:url('feelym/articlecate/updatestatus')}?id=" + data.value + '&status=' + status + '&name=sidebar';


            jq.get(url, function(data) {

                if (data.code == 200) {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 1,
                        time: 1000
                    });
                } else {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 2,
                        anim: 6,
                        time: 1000
                    });
                }
            });
            return false;
        });
        var status = 0;
        form.on('switch(switchtextshow)', function(data) {
            loading = layer.load(2, {
                shade: [0.2, '#000']
            });
            if (data.elem.checked) {
                status = 1;
            } else {
                status = 0;
            }
            var url = "{:url('feelym/articlecate/updatestatus')}?id=" + data.value + '&status=' + status + '&name=hometextshow';


            jq.get(url, function(data) {

                if (data.code == 200) {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 1,
                        time: 1000
                    });
                } else {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 2,
                        anim: 6,
                        time: 1000
                    });
                }
            });
            return false;
        });
        form.on('switch(switchpicshow)', function(data) {
            loading = layer.load(2, {
                shade: [0.2, '#000']
            });
            if (data.elem.checked) {
                status = 1;
            } else {
                status = 0;
            }
            var url = "{:url('feelym/articlecate/updatestatus')}?id=" + data.value + '&status=' + status + '&name=homepicshow';
            jq.get(url, function(data) {

                if (data.code == 200) {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 1,
                        time: 1000
                    });
                } else {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 2,
                        anim: 6,
                        time: 1000
                    });
                }
            });
            return false;
        });
    })
</script>
{/block}